<?php 
	include_once 'checkloginstatus.php';
	include_once '../plugin/fileupload.php';
	include_once '../plugin/imgresize.php';
	include_once '../mysqldb/MySqlHelper.php';
	if (isset($_POST['btnAddPic'])) {
		$save_path=dirname(__FILE__) . '/RTBEditor/attached/ProductImg/';
		$file_name = Upload($save_path,'image','image');
		if($file_name!=false)
		{
			ResizeImage('197', '74', $file_name.'Thum', $save_path,$file_name);
			Save($file_name.'Thum.jpg');
			AlertAndGo('添加成功！', 'productimg.php?pid='.$_POST['pid']);
		}
	}
	function Save($imgUrl){
		$sql = 'insert into ProductShow (imgUrl,ProductName,AddTime,PID) values (\''.$imgUrl.'\',\''.$_POST['txtName'].'\',\''.date("y-m-d h:i:s",time()).'\','.$_POST['pid'].')';
		$MySqlHelper = new MySqlHelper();
		$MySqlHelper->ExecSql($sql);
	}
?>